<?php

class Default_Model_Table_SubPage extends Zend_Db_Table_Abstract {

    protected $_name = 'dynamic_pages';

    public function getPage($id) {
        $id = (int) $id;
        $select = $this->select();
        $select->order('id DESC')
                ->where('id=?', $id);
        $subPage = $this->_db->query($select)->fetchAll();
        if ($subPage != array()) {
            $content = new Default_Model_Table_SubPageContent();
            $contentPage['1'] = $content->getPageContent($subPage['0']['id']);
            $contentCount = (int) count($content);
            $content = $subPage + $contentPage;
            return $content;
        } else {
//        Zend_Debug::dump($content['0']['block_first']);exit();
        }
    }

    public function getPagesToMenu() {
        $select = $this->select();
        $select->from($this->_name, array('id', 'name', 'showin_about',
                                            'showin_services', 'showin_news'))
                ->order('id DESC');
        $subPage = $this->_db->query($select)->fetchAll();
        return $subPage;
    }

}

